<?php
namespace  app\admin\model;
use think\Db;
use think\Model;
Class Admin_model extends Model{
    function __construct($data = [])
    {
        parent::__construct($data);
    }
    //取用户功能
    function  get_rolefunction($role){
        $fun=Db::name('function')->where('user_role',$role)->where('state',1)->order('sort','asc')->select();
        $function=array();
        foreach ($fun as $key =>$value){
            $subfun=Db::name('subfunction')->where('fu_id',$value['id'])->where('state',1)->select();
            if ($subfun){
                $function[$value['name']]=$subfun;
            }else{
                $function[$value['name']]['url']=$value['url'];
            }
        }
        return $function;
    }

}